#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int removeElement(vector<int>& nums, int val)
    {
        vector<int>::iterator itor;
        for (itor = nums.begin(); itor != nums.end();) {
            if (*itor == val)
                itor = nums.erase(itor);
            else
                itor++;
        }
        return nums.size();
    }

    /*better way
    int removeElement(vector<int>& nums, int val)
    {
        int i = 0;
        for (int j = 0; j < nums.size(); j++) {
            if (nums[j] != val) {
                nums[i] = nums[j];
                i++;
            }
        }
        return i;
    }
    */
};

int main(int argc, char const* argv[])
{
    Solution temp;
    int a[10] = { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 };
    vector<int> nums(a, a + 10);
    temp.removeElement(nums, 1);
    return 0;
}